package com.sls.game.dao.maxshu.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.maxshu.MaxshuRechargeDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.maxshu.MaxshuRechargeType;

@Repository("maxshuRechargeDAO")
public class MaxshuRechargeDAOImpl extends SuperDAO<MaxshuRechargeType>
		implements MaxshuRechargeDAO {

	@Override
	public void insertRecharge(MaxshuRechargeType recharge) {
		this.getSqlSession().insert(
				"mybatis.xml.MaxshuRechargeTypeMapper.insert", recharge);

	}

	@Override
	public List<MaxshuRechargeType> queryByProIdAndRechargeName(
			MaxshuRechargeType recharge) {
		return this
				.getSqlSession()
				.selectList(
						"mybatis.xml.MaxshuRechargeTypeMapper.queryByProIdAndRechargeName",
						recharge);
	}

	@Override
	public Pagination<MaxshuRechargeType> queryPage(
			MaxshuRechargeType recharge) {
		Pagination<MaxshuRechargeType> paginationList = null;
		Integer rowCount = queryRowCount(recharge);
		recharge.calculate();
		List<MaxshuRechargeType> list = queryASList(recharge);
		paginationList = this.queryPagination(rowCount, list, recharge);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(MaxshuRechargeType recharge) {
		Integer rowCount = this.getSqlSession()
				.selectOne(
						"mybatis.xml.MaxshuRechargeTypeMapper.queryRowCount",
						recharge);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<MaxshuRechargeType> queryASList(MaxshuRechargeType recharge) {
		List<MaxshuRechargeType> list = this
				.getSqlSession()
				.selectList(
						"mybatis.xml.MaxshuRechargeTypeMapper.queryMaxshuRechargeInfoList",
						recharge);
		return list;
	}

	@Override
	public List<String> queryRechargeNameByProductId(String productId) {
		List<String> list = this
				.getSqlSession()
				.selectList(
						"mybatis.xml.MaxshuRechargeTypeMapper.queryRechargeNameByProductId",
						productId);
		return list;
	}

	@Override
	public void deleteByProductId(String productId) {
		this.getSqlSession().delete(
				"mybatis.xml.MaxshuRechargeTypeMapper.deleteByProductId",
				productId);
	}

}
